package com.pass.four;

import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;

/**
 * For q3
 * 
 * Pass Four: count different lower left corner nodes. It counts # of connected
 * components.
 * 
 * @author bh349
 */
public class PassFour extends Configured implements Tool {

	public int run(String[] args) throws Exception {
		Job job = new Job(getConf(), "pass 4");
		job.setJarByClass(PassFour.class);
		job.setMapperClass(PassFourMapper.class);
		job.setReducerClass(PassFourReducer.class);
		job.setOutputKeyClass(Text.class);
		job.setOutputValueClass(IntWritable.class);
		FileInputFormat.addInputPaths(job, "pass3out");
		FileOutputFormat.setOutputPath(job, new Path("pass4out"));
		return job.waitForCompletion(true) ? 0 : 1;
	}
}
